/***************************************************************************
 appexpressioncontextscopesgenerator.h - AppExpressionContextScopesGenerator

 ---------------------
 begin                : 26.03.2025
 copyright            : (C) 2025 by Mathieu Pellerin
 email                : mathieu (at) opengis.ch
 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef APPEXPRESSIONCONTEXTSCOPESGENERATOR_H
#define APPEXPRESSIONCONTEXTSCOPESGENERATOR_H

#include "gnsspositioninformation.h"
#include "qfieldcloudutils.h"

#include <QObject>

class QgsExpressionContextScope;

/**
 * \ingroup core
 */
class AppExpressionContextScopesGenerator : public QObject
{
    Q_OBJECT

    Q_PROPERTY( GnssPositionInformation positionInformation READ positionInformation WRITE setPositionInformation NOTIFY positionInformationChanged )
    Q_PROPERTY( bool positionLocked READ positionLocked WRITE setPositionLocked NOTIFY positionLockedChanged )
    Q_PROPERTY( CloudUserInformation cloudUserInformation READ cloudUserInformation WRITE setCloudUserInformation NOTIFY cloudUserInformationChanged )

  public:
    explicit AppExpressionContextScopesGenerator( QObject *parent = nullptr );

    /**
     * Returns position information generated by the TransformedPositionSource according to its provider
     */
    GnssPositionInformation positionInformation() const;

    /**
     * Sets position information generated by the TransformedPositionSource according to its provider
     * \param positionInformation the position information
     */
    void setPositionInformation( const GnssPositionInformation &positionInformation );

    /**
     * Returns whether the position is locked to the GNSS
     */
    bool positionLocked() const;

    /**
     * Sets whether the position is locked to the GNSS
     */
    void setPositionLocked( bool positionLocked );

    /**
     * Returns the current cloud user information
     */
    CloudUserInformation cloudUserInformation() const;

    /**
     * Sets the current cloud user information
     * \param cloudUserInformation the cloud user information
     */
    void setCloudUserInformation( const CloudUserInformation &cloudUserInformation );

    QList<QgsExpressionContextScope *> generate();

  signals:
    void positionInformationChanged();
    void positionLockedChanged();
    void cloudUserInformationChanged();

  private:
    GnssPositionInformation mPositionInformation;
    bool mPositionLocked = false;
    CloudUserInformation mCloudUserInformation;
};

#endif // APPEXPRESSIONCONTEXTSCOPESGENERATOR_H
